#!/usr/bin/python3.5

# -*- coding: utf-8 -*-



class Solution:
    def removeElement(self, nums,val):
        k=0
        cur =0

        while cur  < len(nums):

            if val!=nums[cur]:
                nums[k]=nums[cur]
                k += 1
                cur+=1
            else:
                cur+=1

        return k




if __name__=='__main__':
    # arr=[int(x) for x in input().strip().split(' ')]
    arr=[0,1,1,1,2,2,3,3,4]
    solution=Solution()
    k = solution.removeElement(arr,1)
    print(arr[:k])







